<?php echo $this->fetch('header.html'); ?>
<div class="row">
<div class="span12">
<ul class="nav nav-tabs">
    	<li><a href="<?php echo $this->_var['appadmin']; ?>?m=user">用户管理</a></li>
        <li class="active"><a href="<?php echo $this->_var['appadmin']; ?>?m=user&a=add">用户添加</a></li>
    </ul>
<form method="post" action="<?php echo APPADMIN; ?>?m=user&a=save">
<input type="hidden" name="userid" value="<?php echo $this->_var['data']['userid']; ?>">
<table class="table table-bordered" width="100%">

<tr>
    	<td width="18%">账号：</td>
        <td width="82%"><input type="text" name="username" value="<?php echo $this->_var['data']['username']; ?>"></td>
    </tr>
	<tr>
    	<td width="18%">昵称：</td>
        <td width="82%"><input type="text" name="nickname" value="<?php echo $this->_var['data']['nickname']; ?>"></td>
    </tr>
    
    <tr>
    	<td>邮箱：</td>
        <td><?php if ($this->_var['data']['email']): ?><?php echo $this->_var['data']['email']; ?><?php else: ?><input type="text" name="email" value="" /><?php endif; ?></td>
    </tr>
    
    <tr>
	  <td>手机：</td>
	  <td><input name="telephone" type="text" id="telephone" value="<?php echo $this->_var['data']['telephone']; ?>"></td>
	  </tr>
	<tr>
    
    <tr>
    	<td>密码：</td>
        <td><input type="text" name="password" /></td>
    </tr>
    <tr>
    	<td>重复密码：</td>
        <td><input type="text" name="password2" /></td>
    </tr>
    
    <tr>
    	<td>头像</td>
        <td>
        <div class="btn-upload">
        <input type="file" name="upimg" id="upimg" class="btn-upload-file" onChange="uploadgoodsimg()">
        </div>
      <label  id="loading" style="color:red; display:none;">正在上传中...</label>
      <input type="hidden" name="user_head" id="imgurl" value="<?php echo $this->_var['data']['user_head']; ?>">
      <span id="imgShow">
      <?php if ($this->_var['data']['user_head']): ?>
      <img src="<?php echo IMAGES_SITE($this->_var['data']['user_head']); ?>.100x100.jpg">
      <?php endif; ?>
      </span></td>
    </tr>
    
	<tr>
	  <td>身份证：</td>
	  <td><input name="user_card" type="text" id="user_card" value="<?php echo $this->_var['data']['user_card']; ?>"></td>
	  </tr>
	<tr>
	  <td>真实姓名：</td>
	  <td><input name="truename" type="text" id="truename" value="<?php echo $this->_var['data']['truename']; ?>"></td>
	  </tr>
	
	  <td>实名认证：</td>
	  <td><select name="is_auth">
      	<option value="1" <?php if ($this->_var['data']['is_auth'] == 1): ?> selected<?php endif; ?>>已通过</option>
        <option value="2" <?php if ($this->_var['data']['is_auth'] == 2): ?> selected<?php endif; ?>>未通过</option>
        <option value="3" <?php if ($this->_var['data']['is_auth'] == 3): ?> selected<?php endif; ?>>待审核</option>
      </select></td>
	  </tr>
	<tr>
	  <td>用户类型：</td>
	  <td><select name="user_type">
      	<?php $_from = $this->_var['user_type_list']; if (!is_array($_from) && !is_object($_from)) { $_from=array();}; $this->push_vars('k', 'c');if (count($_from)):
    foreach ($_from AS $this->_var['k'] => $this->_var['c']):
?>
        <option value="<?php echo $this->_var['k']; ?>" <?php if ($this->_var['k'] == $this->_var['data']['user_type']): ?> selected<?php endif; ?>><?php echo $this->_var['c']; ?></option>
        <?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
      </select></td>
	  </tr>
	<tr>
	  <td>账户状态：</td>
	  <td><select name="status">
      	<option  value="99" <?php if ($this->_var['data']['status'] == 99): ?> selected<?php endif; ?>>已禁止</option>
      	<option value="1" <?php if ($this->_var['data']['status'] == 1): ?> selected<?php endif; ?>>已通过</option>
        <option value="10"  <?php if ($this->_var['data']['status'] == 10): ?> selected<?php endif; ?>>待审核</option>
      </select></td>
	  </tr>
	<tr>
	  <td>允许投稿</td>
	  <td><select name="is_post">
      		<option value="2" <?php if ($this->_var['data']['is_post'] == 2): ?> selected="selected"<?php endif; ?>>不允许</option>
            <option value="1"  <?php if ($this->_var['data']['is_post'] == 1): ?> selected="selected"<?php endif; ?>>允许</option>
      	</select></td>
	  </tr>
	<tr>
	  <td>&nbsp;</td>
	  <td><input type="submit" name="button" id="button" class="btn btn-success" value="保存"></td>
	  </tr>
    
    
</table>
</form>

</div>
</div>
<script language="javascript" src="/plugin/jquery/ajaxfileupload.js"></script>
<script language="javascript">
   function uploadgoodsimg()
    {
        //starting setting some animation when the ajax starts and completes
        $("#loading")
        .ajaxStart(function(){
            $(this).show();
        })
        .ajaxComplete(function(){
            $(this).hide();
        });

        $.ajaxFileUpload
        (
            {
                url:'/index.php?m=upload&a=uploadtao&t='+Math.random(), 
                secureuri:false,
                fileElementId:'upimg',
                dataType: 'json',
                success: function (data, status)
                {
                    if(typeof(data.error) != 'undefined')
                    {
                        if(data.error != '')
                        {
                           alert(data.msg);
                        }else
                        {
                             $("#imgShow").html("<img src='/"+data.imgurl+".100x100.jpg' width='100'>");
							 $("#imgurl").val(data.imgurl);
                        }
                    }
                },
                error: function (data, status, e)
                {
                    alert(e);
                }
            }
        )
        
        return false;

    }
</script>

<?php echo $this->fetch('footer.html'); ?>